package com.robot.thread;

import com.robot.service.BuildTestService;
import com.robot.service.MailReportService;
import com.robot.service.RunTestService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * Created with IntelliJ IDEA.
 * User: li
 * Date: 2020/3/22
 * Time: 14:32
 * PROJECT：robot
 * PACKAGE: com.robot
 *
 * @author:55324936@qq.com To change this template use File | Settings | File Templates.
 */
@Data
@Slf4j
public class TestPlanTask implements Runnable {

    private Integer testPlanId;

    private BuildTestService buildTestService;

    private RunTestService runTestService;

    private ThreadPoolTaskExecutor executor;

    private MailReportService mailReportService;

    @Override
    public void run() {
        Integer buildTestId=buildTestService.saveBuildTestPlan(this.getTestPlanId());
        try {
            /**多线程，异步执行**/
            ThreadRunTest threadRunTest=new ThreadRunTest(buildTestId,runTestService,mailReportService);
            executor.execute(threadRunTest);
        } catch (Exception e) {
            log.error("调用异常!", e);
        }
    }
}

